.class public Lrexsee/core/notification/RexseeNotification;
.super Ljava/lang/Object;
.source "RexseeNotification.java"

# interfaces
.implements Lrexsee/core/browser/clazz/JavascriptInterface;


# static fields
.field private static final INTERFACE_NAME:Ljava/lang/String; = "Notification"

.field public static final PREFIX_LAYOUT:Ljava/lang/String; = "layout_notification_"

.field public static final PREFIX_LAYOUT_MESSAGE:Ljava/lang/String; = "notificationText_"

.field public static final PREFIX_LAYOUT_TITLE:Ljava/lang/String; = "notificationTitle_"


# instance fields
.field private final mBrowser:Lrexsee/core/browser/Browser;

.field private final mContext:Landroid/content/Context;


# direct methods
.method public constructor <init>(Landroid/content/Context;)V
    .locals 1
    .param p1, "context"    # Landroid/content/Context;

    .prologue
    .line 42
    invoke-direct {p0}, Ljava/lang/Object;-><init>()V

    .line 43
    iput-object p1, p0, Lrexsee/core/notification/RexseeNotification;->mContext:Landroid/content/Context;

    .line 44
    const/4 v0, 0x0

    iput-object v0, p0, Lrexsee/core/notification/RexseeNotification;->mBrowser:Lrexsee/core/browser/Browser;

    .line 45
    return-void
.end method

.method public constructor <init>(Lrexsee/core/browser/Browser;)V
    .locals 1
    .param p1, "browser"    # Lrexsee/core/browser/Browser;

    .prologue
    .line 47
    invoke-direct {p0}, Ljava/lang/Object;-><init>()V

    .line 48
    invoke-virtual {p1}, Lrexsee/core/browser/Browser;->getContext()Landroid/content/Context;

    move-result-object v0

    iput-object v0, p0, Lrexsee/core/notification/RexseeNotification;->mContext:Landroid/content/Context;

    .line 49
    iput-object p1, p0, Lrexsee/core/notification/RexseeNotification;->mBrowser:Lrexsee/core/browser/Browser;

    .line 50
    return-void
.end method


# virtual methods
.method public getInheritInterface(Lrexsee/core/browser/Browser;)Lrexsee/core/browser/clazz/JavascriptInterface;
    .locals 0
    .param p1, "childBrowser"    # Lrexsee/core/browser/Browser;

    .prologue
    .line 28
    return-object p0
.end method

.method public getInterfaceName()Ljava/lang/String;
    .locals 2

    .prologue
    .line 24
    iget-object v0, p0, Lrexsee/core/notification/RexseeNotification;->mBrowser:Lrexsee/core/browser/Browser;

    if-nez v0, :cond_0

    const/4 v0, 0x0

    :goto_0
    return-object v0

    :cond_0
    new-instance v0, Ljava/lang/StringBuilder;

    iget-object v1, p0, Lrexsee/core/notification/RexseeNotification;->mBrowser:Lrexsee/core/browser/Browser;

    iget-object v1, v1, Lrexsee/core/browser/Browser;->application:Lrexsee/core/application/RexseeApplication;

    iget-object v1, v1, Lrexsee/core/application/RexseeApplication;->resources:Lrexsee/core/application/Resource;

    iget-object v1, v1, Lrexsee/core/application/Resource;->prefix:Ljava/lang/String;

    invoke-static {v1}, Ljava/lang/String;->valueOf(Ljava/lang/Object;)Ljava/lang/String;

    move-result-object v1

    invoke-direct {v0, v1}, Ljava/lang/StringBuilder;-><init>(Ljava/lang/String;)V

    const-string v1, "Notification"

    invoke-virtual {v0, v1}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    move-result-object v0

    invoke-virtual {v0}, Ljava/lang/StringBuilder;->toString()Ljava/lang/String;

    move-result-object v0

    goto :goto_0
.end method

.method public getLayout(Ljava/lang/String;)Lrexsee/core/notification/NotificationLayout;
    .locals 7
    .param p1, "name"    # Ljava/lang/String;

    .prologue
    const/4 v5, 0x0

    const-string v6, "id"

    .line 54
    if-eqz p1, :cond_0

    const-string v3, ""

    invoke-virtual {p1, v3}, Ljava/lang/String;->equals(Ljava/lang/Object;)Z

    move-result v3

    if-eqz v3, :cond_1

    :cond_0
    move-object v3, v5

    .line 65
    :goto_0
    return-object v3

    .line 56
    :cond_1
    new-instance v0, Lrexsee/core/notification/NotificationLayout;

    invoke-direct {v0}, Lrexsee/core/notification/NotificationLayout;-><init>()V

    .line 58
    .local v0, "layout":Lrexsee/core/notification/NotificationLayout;
    iget-object v3, p0, Lrexsee/core/notification/RexseeNotification;->mContext:Landroid/content/Context;

    invoke-virtual {v3}, Landroid/content/Context;->getPackageName()Ljava/lang/String;

    move-result-object v1

    .line 59
    .local v1, "packageName":Ljava/lang/String;
    iget-object v3, p0, Lrexsee/core/notification/RexseeNotification;->mContext:Landroid/content/Context;

    invoke-virtual {v3}, Landroid/content/Context;->getResources()Landroid/content/res/Resources;

    move-result-object v2

    .line 61
    .local v2, "r":Landroid/content/res/Resources;
    new-instance v3, Ljava/lang/StringBuilder;

    const-string v4, "layout_notification_"

    invoke-direct {v3, v4}, Ljava/lang/StringBuilder;-><init>(Ljava/lang/String;)V

    invoke-virtual {v3, p1}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    move-result-object v3

    invoke-virtual {v3}, Ljava/lang/StringBuilder;->toString()Ljava/lang/String;

    move-result-object v3

    const-string v4, "layout"

    invoke-virtual {v2, v3, v4, v1}, Landroid/content/res/Resources;->getIdentifier(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;)I

    move-result v3

    iput v3, v0, Lrexsee/core/notification/NotificationLayout;->layout:I

    .line 62
    new-instance v3, Ljava/lang/StringBuilder;

    const-string v4, "notificationTitle_"

    invoke-direct {v3, v4}, Ljava/lang/StringBuilder;-><init>(Ljava/lang/String;)V

    invoke-virtual {v3, p1}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    move-result-object v3

    invoke-virtual {v3}, Ljava/lang/StringBuilder;->toString()Ljava/lang/String;

    move-result-object v3

    const-string v4, "id"

    invoke-virtual {v2, v3, v6, v1}, Landroid/content/res/Resources;->getIdentifier(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;)I

    move-result v3

    iput v3, v0, Lrexsee/core/notification/NotificationLayout;->title:I

    .line 63
    new-instance v3, Ljava/lang/StringBuilder;

    const-string v4, "notificationText_"

    invoke-direct {v3, v4}, Ljava/lang/StringBuilder;-><init>(Ljava/lang/String;)V

    invoke-virtual {v3, p1}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    move-result-object v3

    invoke-virtual {v3}, Ljava/lang/StringBuilder;->toString()Ljava/lang/String;

    move-result-object v3

    const-string v4, "id"

    invoke-virtual {v2, v3, v6, v1}, Landroid/content/res/Resources;->getIdentifier(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;)I

    move-result v3

    iput v3, v0, Lrexsee/core/notification/NotificationLayout;->message:I

    .line 65
    iget v3, v0, Lrexsee/core/notification/NotificationLayout;->layout:I

    if-eqz v3, :cond_2

    iget v3, v0, Lrexsee/core/notification/NotificationLayout;->title:I

    if-eqz v3, :cond_2

    iget v3, v0, Lrexsee/core/notification/NotificationLayout;->message:I

    if-nez v3, :cond_3

    :cond_2
    move-object v3, v5

    goto :goto_0

    :cond_3
    move-object v3, v0

    goto :goto_0
.end method

.method public getNewInterface(Lrexsee/core/browser/Browser;)Lrexsee/core/browser/clazz/JavascriptInterface;
    .locals 1
    .param p1, "childBrowser"    # Lrexsee/core/browser/Browser;

    .prologue
    .line 32
    new-instance v0, Lrexsee/core/notification/RexseeNotification;

    invoke-direct {v0, p1}, Lrexsee/core/notification/RexseeNotification;-><init>(Lrexsee/core/browser/Browser;)V

    return-object v0
.end method

.method public hide(I)V
    .locals 2
    .param p1, "id"    # I

    .prologue
    .line 120
    iget-object v0, p0, Lrexsee/core/notification/RexseeNotification;->mContext:Landroid/content/Context;

    const-string v1, "notification"

    invoke-virtual {v0, v1}, Landroid/content/Context;->getSystemService(Ljava/lang/String;)Ljava/lang/Object;

    move-result-object p0

    .end local p0    # "this":Lrexsee/core/notification/RexseeNotification;
    check-cast p0, Landroid/app/NotificationManager;

    invoke-virtual {p0, p1}, Landroid/app/NotificationManager;->cancel(I)V

    .line 121
    return-void
.end method

.method public show(Ljava/lang/String;)V
    .locals 1
    .param p1, "arguments"    # Ljava/lang/String;

    .prologue
    .line 116
    if-nez p1, :cond_0

    .line 118
    :goto_0
    return-void

    .line 117
    :cond_0
    new-instance v0, Lrexsee/core/notification/NotificationArgumentsSheet;

    invoke-direct {v0}, Lrexsee/core/notification/NotificationArgumentsSheet;-><init>()V

    invoke-virtual {v0, p1}, Lrexsee/core/notification/NotificationArgumentsSheet;->parseArguments(Ljava/lang/String;)Lrexsee/core/notification/NotificationArgumentsSheet;

    move-result-object v0

    invoke-virtual {p0, v0}, Lrexsee/core/notification/RexseeNotification;->show(Lrexsee/core/notification/NotificationArgumentsSheet;)V

    goto :goto_0
.end method

.method public show(Lrexsee/core/notification/NotificationArgumentsSheet;)V
    .locals 13
    .param p1, "argu"    # Lrexsee/core/notification/NotificationArgumentsSheet;

    .prologue
    const-string v12, ""

    .line 71
    if-nez p1, :cond_1

    .line 112
    :cond_0
    :goto_0
    return-void

    .line 72
    :cond_1
    iget-object v10, p1, Lrexsee/core/notification/NotificationArgumentsSheet;->title:Ljava/lang/String;

    const-string v11, ""

    invoke-virtual {v10, v12}, Ljava/lang/String;->equals(Ljava/lang/Object;)Z

    move-result v10

    if-eqz v10, :cond_2

    iget-object v10, p1, Lrexsee/core/notification/NotificationArgumentsSheet;->message:Ljava/lang/String;

    const-string v11, ""

    invoke-virtual {v10, v12}, Ljava/lang/String;->equals(Ljava/lang/Object;)Z

    move-result v10

    if-nez v10, :cond_0

    .line 74
    :cond_2
    invoke-virtual {p1}, Lrexsee/core/notification/NotificationArgumentsSheet;->getId()I

    move-result v3

    .line 77
    .local v3, "id":I
    iget-object v10, p1, Lrexsee/core/notification/NotificationArgumentsSheet;->url:Ljava/lang/String;

    const-string v11, ""

    invoke-virtual {v10, v12}, Ljava/lang/String;->compareTo(Ljava/lang/String;)I

    move-result v10

    if-eqz v10, :cond_4

    .line 78
    new-instance v4, Landroid/content/Intent;

    iget-object v10, p0, Lrexsee/core/notification/RexseeNotification;->mContext:Landroid/content/Context;

    const-class v11, Lrexsee/core/receiver/_Receiver;

    invoke-direct {v4, v10, v11}, Landroid/content/Intent;-><init>(Landroid/content/Context;Ljava/lang/Class;)V

    .line 79
    .local v4, "intent":Landroid/content/Intent;
    iget-object v10, p1, Lrexsee/core/notification/NotificationArgumentsSheet;->url:Ljava/lang/String;

    invoke-static {v10}, Landroid/net/Uri;->parse(Ljava/lang/String;)Landroid/net/Uri;

    move-result-object v10

    invoke-virtual {v4, v10}, Landroid/content/Intent;->setData(Landroid/net/Uri;)Landroid/content/Intent;

    .line 81
    :goto_1
    iget-object v10, p0, Lrexsee/core/notification/RexseeNotification;->mContext:Landroid/content/Context;

    const/4 v11, 0x0

    const/high16 v12, 0x8000000

    invoke-static {v10, v11, v4, v12}, Landroid/app/PendingIntent;->getBroadcast(Landroid/content/Context;ILandroid/content/Intent;I)Landroid/app/PendingIntent;

    move-result-object v8

    .line 83
    .local v8, "pendingIntent":Landroid/app/PendingIntent;
    new-instance v6, Landroid/app/Notification;

    invoke-direct {v6}, Landroid/app/Notification;-><init>()V

    .line 84
    .local v6, "notification":Landroid/app/Notification;
    invoke-virtual {p1}, Lrexsee/core/notification/NotificationArgumentsSheet;->getFlags()I

    move-result v10

    iput v10, v6, Landroid/app/Notification;->flags:I

    .line 85
    invoke-virtual {p1}, Lrexsee/core/notification/NotificationArgumentsSheet;->getDefaults()I

    move-result v10

    iput v10, v6, Landroid/app/Notification;->defaults:I

    .line 88
    :try_start_0
    iget-object v10, p0, Lrexsee/core/notification/RexseeNotification;->mContext:Landroid/content/Context;

    invoke-virtual {v10}, Landroid/content/Context;->getPackageManager()Landroid/content/pm/PackageManager;

    move-result-object v10

    iget-object v11, p0, Lrexsee/core/notification/RexseeNotification;->mContext:Landroid/content/Context;

    invoke-virtual {v11}, Landroid/content/Context;->getPackageName()Ljava/lang/String;

    move-result-object v11

    const/16 v12, 0x80

    invoke-virtual {v10, v11, v12}, Landroid/content/pm/PackageManager;->getApplicationInfo(Ljava/lang/String;I)Landroid/content/pm/ApplicationInfo;
    :try_end_0
    .catch Landroid/content/pm/PackageManager$NameNotFoundException; {:try_start_0 .. :try_end_0} :catch_0

    move-result-object v0

    .line 92
    .local v0, "appInfo":Landroid/content/pm/ApplicationInfo;
    :goto_2
    if-nez v0, :cond_5

    const v10, 0x108009b

    :goto_3
    iput v10, v6, Landroid/app/Notification;->icon:I

    .line 93
    iget-object v10, p1, Lrexsee/core/notification/NotificationArgumentsSheet;->ticker:Ljava/lang/String;

    invoke-static {v10}, Landroid/text/Html;->fromHtml(Ljava/lang/String;)Landroid/text/Spanned;

    move-result-object v10

    iput-object v10, v6, Landroid/app/Notification;->tickerText:Ljava/lang/CharSequence;

    .line 94
    invoke-virtual {p1}, Lrexsee/core/notification/NotificationArgumentsSheet;->getWhen()J

    move-result-wide v10

    iput-wide v10, v6, Landroid/app/Notification;->when:J

    .line 97
    invoke-virtual {p1}, Lrexsee/core/notification/NotificationArgumentsSheet;->getSound()Landroid/net/Uri;

    move-result-object v9

    .line 98
    .local v9, "soundUri":Landroid/net/Uri;
    if-eqz v9, :cond_3

    iput-object v9, v6, Landroid/app/Notification;->sound:Landroid/net/Uri;

    .line 100
    :cond_3
    iget-object v10, p1, Lrexsee/core/notification/NotificationArgumentsSheet;->layout:Ljava/lang/String;

    invoke-virtual {p0, v10}, Lrexsee/core/notification/RexseeNotification;->getLayout(Ljava/lang/String;)Lrexsee/core/notification/NotificationLayout;

    move-result-object v5

    .line 101
    .local v5, "layout":Lrexsee/core/notification/NotificationLayout;
    if-nez v5, :cond_6

    .line 102
    iget-object v10, p0, Lrexsee/core/notification/RexseeNotification;->mContext:Landroid/content/Context;

    iget-object v11, p1, Lrexsee/core/notification/NotificationArgumentsSheet;->title:Ljava/lang/String;

    invoke-static {v11}, Landroid/text/Html;->fromHtml(Ljava/lang/String;)Landroid/text/Spanned;

    move-result-object v11

    iget-object v12, p1, Lrexsee/core/notification/NotificationArgumentsSheet;->message:Ljava/lang/String;

    invoke-static {v12}, Landroid/text/Html;->fromHtml(Ljava/lang/String;)Landroid/text/Spanned;

    move-result-object v12

    invoke-virtual {v6, v10, v11, v12, v8}, Landroid/app/Notification;->setLatestEventInfo(Landroid/content/Context;Ljava/lang/CharSequence;Ljava/lang/CharSequence;Landroid/app/PendingIntent;)V

    .line 110
    :goto_4
    iget-object v10, p0, Lrexsee/core/notification/RexseeNotification;->mContext:Landroid/content/Context;

    const-string v11, "notification"

    invoke-virtual {v10, v11}, Landroid/content/Context;->getSystemService(Ljava/lang/String;)Ljava/lang/Object;

    move-result-object v7

    check-cast v7, Landroid/app/NotificationManager;

    .line 111
    .local v7, "notificationManager":Landroid/app/NotificationManager;
    invoke-virtual {v7, v3, v6}, Landroid/app/NotificationManager;->notify(ILandroid/app/Notification;)V

    goto/16 :goto_0

    .line 80
    .end local v0    # "appInfo":Landroid/content/pm/ApplicationInfo;
    .end local v4    # "intent":Landroid/content/Intent;
    .end local v5    # "layout":Lrexsee/core/notification/NotificationLayout;
    .end local v6    # "notification":Landroid/app/Notification;
    .end local v7    # "notificationManager":Landroid/app/NotificationManager;
    .end local v8    # "pendingIntent":Landroid/app/PendingIntent;
    .end local v9    # "soundUri":Landroid/net/Uri;
    :cond_4
    new-instance v4, Landroid/content/Intent;

    invoke-direct {v4}, Landroid/content/Intent;-><init>()V

    .restart local v4    # "intent":Landroid/content/Intent;
    goto :goto_1

    .line 89
    .restart local v6    # "notification":Landroid/app/Notification;
    .restart local v8    # "pendingIntent":Landroid/app/PendingIntent;
    :catch_0
    move-exception v10

    move-object v2, v10

    .line 90
    .local v2, "e":Landroid/content/pm/PackageManager$NameNotFoundException;
    const/4 v0, 0x0

    .restart local v0    # "appInfo":Landroid/content/pm/ApplicationInfo;
    goto :goto_2

    .line 92
    .end local v2    # "e":Landroid/content/pm/PackageManager$NameNotFoundException;
    :cond_5
    iget v10, v0, Landroid/content/pm/ApplicationInfo;->icon:I

    goto :goto_3

    .line 104
    .restart local v5    # "layout":Lrexsee/core/notification/NotificationLayout;
    .restart local v9    # "soundUri":Landroid/net/Uri;
    :cond_6
    new-instance v1, Landroid/widget/RemoteViews;

    iget-object v10, p0, Lrexsee/core/notification/RexseeNotification;->mContext:Landroid/content/Context;

    invoke-virtual {v10}, Landroid/content/Context;->getPackageName()Ljava/lang/String;

    move-result-object v10

    iget v11, v5, Lrexsee/core/notification/NotificationLayout;->layout:I

    invoke-direct {v1, v10, v11}, Landroid/widget/RemoteViews;-><init>(Ljava/lang/String;I)V

    .line 105
    .local v1, "contentView":Landroid/widget/RemoteViews;
    iget v10, v5, Lrexsee/core/notification/NotificationLayout;->title:I

    iget-object v11, p1, Lrexsee/core/notification/NotificationArgumentsSheet;->title:Ljava/lang/String;

    invoke-static {v11}, Landroid/text/Html;->fromHtml(Ljava/lang/String;)Landroid/text/Spanned;

    move-result-object v11

    invoke-virtual {v1, v10, v11}, Landroid/widget/RemoteViews;->setTextViewText(ILjava/lang/CharSequence;)V

    .line 106
    iget v10, v5, Lrexsee/core/notification/NotificationLayout;->message:I

    iget-object v11, p1, Lrexsee/core/notification/NotificationArgumentsSheet;->message:Ljava/lang/String;

    invoke-static {v11}, Landroid/text/Html;->fromHtml(Ljava/lang/String;)Landroid/text/Spanned;

    move-result-object v11

    invoke-virtual {v1, v10, v11}, Landroid/widget/RemoteViews;->setTextViewText(ILjava/lang/CharSequence;)V

    .line 107
    iput-object v1, v6, Landroid/app/Notification;->contentView:Landroid/widget/RemoteViews;

    .line 108
    iput-object v8, v6, Landroid/app/Notification;->contentIntent:Landroid/app/PendingIntent;

    goto :goto_4
.end method
